package com.lei.day05lx;

import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.lei.day05lx.contract.LoginContract;
import com.lei.day05lx.model.LoginModel;
import com.lei.day05lx.presenter.LoginPresenter;
import com.lei.tong.mvp.view.BaseActivty;

public class MainActivity extends BaseActivty<LoginPresenter> implements LoginContract.View {
    private EditText etNameLog;
    private EditText etPwdLog;
    private Button btLogin;
    private Button btRegister;
    private Button btDxc;
    private TextView tvDxc;
    private LoginPresenter loginPresenter;

    @Override
    public String getuser() {
        return etNameLog.getText().toString().trim();
    }

    @Override
    public String getpwd() {
        return etPwdLog.getText().toString().trim();
    }

    @Override
    public void Dxc(String json) {
        tvDxc.setText(json);
    }

    @Override
    public int bindlayout() {
        return R.layout.activity_main;
    }

    @Override
    public void initview() {
        etNameLog = (EditText) findViewById(R.id.et_name_log);
        etPwdLog = (EditText) findViewById(R.id.et_pwd_log);
        btLogin = (Button) findViewById(R.id.bt_login);
        btRegister = (Button) findViewById(R.id.bt_register);
        btDxc = (Button) findViewById(R.id.bt_dxc);
        tvDxc = (TextView) findViewById(R.id.tv_dxc);
        btLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                loginPresenter.login();
            }
        });
        btRegister.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                loginPresenter.register();
            }
        });
        btDxc.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                loginPresenter.initdata();
            }
        });
    }

    @Override
    public void inject() {
        loginPresenter = new LoginPresenter(new LoginModel(),this);
    }

    @Override
    public void initdata() {

    }
}
